package cn.zl.rtsp.response;

import cn.zl.ZLMediaServer;
import cn.zl.rtsp.response.core.DescribeRTSPResponse;
import cn.zl.rtsp.response.core.OptionRTSPResponse;
import cn.zl.rtsp.response.core.PlayRTSPResponse;
import cn.zl.rtsp.response.core.SetupRTSPResponse;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.DefaultHttpRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Optional;

public class RTSPResponseFactory {

    private static final Logger logger = LoggerFactory.getLogger(RTSPResponseFactory.class);


    public static Optional<RTSPResponse> create(String method, ChannelHandlerContext context, DefaultHttpRequest request){
        if("OPTIONS".equals(method)){
            return Optional.of(new OptionRTSPResponse(context, request));
        } else if("DESCRIBE".equals(method)){
            return Optional.of(new DescribeRTSPResponse(context, request));
        } else if("SETUP".equals(method)){
            return Optional.of(new SetupRTSPResponse(context, request));
        } else if("PLAY".equals(method)){
            return Optional.of(new PlayRTSPResponse(context, request));
        } else {
            logger.info("not support method: {}", method);
        }
        return Optional.empty();
    }

}
